home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 / Ham Radio 2000.iso / ham2000 / packet / terminal / top_152 / src152.exe / rar / TOPSCROL.PAS < prev    next >
Pascal/Delphi Source File  |  1995-05-16  |  66KB  |  1,994 lines

  1. {┌─────────────────────────────────────────────────────────────────────────┐}
  2. {│                                                                         │}
  3. {│                              T. O. P.                                   │}
  4. {│                                                                         │}
  5. {│                        (T)he  (O)ther  (P)acket                         │}
  6. {│                                                                         │}
  7. {│ T O P S C R O L . P A S                                                 │}
  8. {│                                                                         │}
  9. {│                                                                         │}
  10. {│ Routinen für den Backscroll des QSO-Fensters (Hauptbildschirm)          │}
  11. {└─────────────────────────────────────────────────────────────────────────┘}
  12.  
  13.  
  14. Procedure Notiz_Zeigen (* Kanal : Byte *);
  15.  
  16. Type      RetPtr    = array[0..maxNotLines] of Word;
  17.           AttPtr    = array[0..maxNotLines] of Boolean;
  18.  
  19. Var       Groesse   : LongInt;
  20.           Zeilen,
  21.           abline,
  22.           von,bis,
  23.           i,i1,P,
  24.           X,Y,XB,
  25.           Result    : Integer;
  26.           StartPage,
  27.           StopPage,
  28.           Z         : Word;
  29.           b,Nx,
  30.           AMark,
  31.           AMerk     : Byte;
  32.           MoStr     : String[80];
  33.           Save_Name : String[60];
  34.           Suchstr   : String[30];
  35.           ablineStr : String[19];
  36.           BlStr,
  37.           Zstr      : String[2];
  38.           KC        : Sondertaste;
  39.           VC        : Char;
  40.           NSave     : Text;
  41.           RetFlag,
  42.           gefunden,
  43.           fertig,
  44.           PFlag,
  45.           VorEdit,
  46.           MarkBlock,
  47.           NowBlock,
  48.           NowZlnMerk,
  49.           CurObStat : Boolean;
  50.           RET       : ^RetPtr;
  51.           BlAttr    : ^AttPtr;
  52.  
  53. Label Nochmal,
  54.       Nochmal1;
  55.  
  56.   Procedure GetRam;
  57.   Var    i : Word;
  58.   Begin
  59.     if not MarkBlock then
  60.     begin
  61.       GetMem(BlAttr,Zeilen);
  62.       FillChar(BlAttr^,Zeilen,0);
  63.       for i := 1 to Zeilen do BlAttr^[i] := false;
  64.       MarkBlock := true;
  65.     end;
  66.   End;
  67.  
  68.   Function Eig(Nr : Word) : Str2;
  69.   Begin
  70.     if (Kanal > 0) and (Page^[RET^[Nr]+1] = Attrib[19]) then Eig := EchoCh
  71.                                                         else Eig := '';
  72.   End;
  73.  
  74.   Procedure Array_updaten(Kanal : Byte);
  75.   Var    NotPtr,
  76.          CRPtr     : Pointer;
  77.          max       : Word;
  78.          ZL        : Integer;
  79.   Begin
  80.     with K[Kanal]^ do
  81.     begin
  82.       FillChar(Page^,maxNotCh,0);
  83.       if use_EMS then EMS_Seite_einblenden(Kanal,Scr);
  84.  
  85.       if use_Vdisk then
  86.       begin
  87.         FiResult := ResetBin(ScrollFile,T);
  88.  
  89.         Seek(ScrollFile,Pos_im_Scr + NotPos);
  90.         Blockread(ScrollFile,Page^[0],maxNotCh-1-NotPos,Z);
  91.  
  92.         Seek(ScrollFile,Pos_im_Scr);
  93.         Blockread(ScrollFile,Page^[maxNotCh-1-NotPos],NotPos,Z);
  94.  
  95.         FiResult := CloseBin(ScrollFile);
  96.       end else
  97.       if use_XMS then
  98.       begin
  99.         XMS_to_Data(@Page^[0],XMS_Handle,Pos_im_Scr+NotPos,maxNotCh-1-NotPos);
  100.         XMS_to_Data(@Page^[maxNotCh-1-NotPos],XMS_Handle,Pos_im_Scr,NotPos);
  101.       end else
  102.       begin
  103.         move(NotCh[Kanal]^[NotPos],Page^[0],maxNotCh-1-NotPos);
  104.         move(NotCh[Kanal]^[0],Page^[maxNotCh-1-NotPos],NotPos);
  105.       end;
  106.       Page^[maxNotCh-1] := 13;
  107.       max := maxNotCh;
  108.     end;
  109.  
  110.     NotPtr := @Page^[0];
  111.     CRPtr := @RET^[1];
  112.  
  113.     asm  push ds
  114.          mov  cx, max
  115.          mov  bx, 0
  116.          mov  dx, 0
  117.          les  di, CRPtr
  118.          lds  si, NotPtr
  119.          jmp  @Weiter
  120.     @CR:
  121.          mov  [es:di], bx
  122.          add  di, 2
  123.          inc  dx
  124.          jmp  @Again
  125. @Weiter:
  126.          mov  al, [ds:si]
  127.          cmp  al, 13
  128.          je   @CR
  129.  @Again:
  130.          inc  si
  131.          inc  bx
  132.          Loop @Weiter
  133.          pop  ds
  134.          mov  ZL, dx
  135.     end;
  136.     Zeilen := ZL;
  137.  
  138.     (*
  139.     for ZL := 0 to K[Kanal]^.maxNotCh-1 do
  140.     begin
  141.       if Page^[ZL] = 13 then
  142.       begin
  143.         inc(Zeilen);
  144.         RET^[Zeilen] := ZL;
  145.       end;
  146.     end;
  147.     *)
  148.  
  149.     dec(Zeilen);
  150.     if Zeilen <= 0 then Zeilen := 1;
  151.   end;
  152.  
  153.  
  154.   Function BringZeile(Kanal : Byte; Nr : Integer) : String;
  155.   var      P    : Word;
  156.            Hstr : String;
  157.            Ze   : Byte;
  158.   begin
  159.     with K[Kanal]^ do
  160.     begin
  161.       Hstr := '';
  162.       for P := (RET^[Nr]+2) to (RET^[Nr+1]-1) do
  163.       begin
  164.         Ze := Page^[P];
  165.         if Ze in [1..31] then
  166.         begin
  167.           Ze := Ze + 64;
  168.           Hstr := Hstr + '^';
  169.         end;
  170.         Hstr := Hstr + chr(Ze);
  171.       end;
  172.       BringZeile := Hstr;
  173.     end;
  174.   end;
  175.  
  176.   Procedure Zeig(Kanal,von,bis : Byte; PLine : Integer);
  177.   var       i,i1,j,
  178.             Attr   : Byte;
  179.             Hstr   : String[80];
  180.   Begin
  181.     i1 := 0;
  182.     if Zeilen > 1 then for i := von to bis do
  183.     begin
  184.       Attr := Page^[RET^[PLine+i1]+1];
  185.       if Attr = 254 then Attr := 13;
  186.       if (MarkBlock and BlAttr^[PLine+i1]) or ((i = Y) and not MarkBlock)
  187.          then Attr := Attrib[4];
  188.       FillChar(Hstr[1],80,32);
  189.       Hstr[0] := Chr(80);
  190.       j := Byte(RET^[PLine+i1+1] - RET^[PLine+i1] - 2);
  191.       if j > 80 then j := 80;
  192.       move(Page^[RET^[PLine+i1]+2],Hstr[1],j);
  193.       WritePage(Kanal,1,i,Attr,0,Hstr);
  194.       inc(i1);
  195.     end;
  196.   End;
  197.  
  198.   Procedure CursorUp(Kanal : Byte);
  199.   Begin
  200.     if abline + Y - von > 1 then
  201.     begin
  202.       dec(Y);
  203.       if Y < von then
  204.       begin
  205.         Y := von;
  206.         dec(abline);
  207.         Scroll(Dn,1,von,bis);
  208.       end;
  209.       Zeig(Kanal,Y,Y+1,abline + Y - von);
  210.     end;
  211.   End;
  212.  
  213.   Procedure CursorDown(Ka : Byte);
  214.   Var   Merk : Integer;
  215.         Flag : Boolean;
  216.   Begin
  217.     Flag := false;
  218.     if (K[Ka]^.NeueZeilen > 0) and not MarkBlock and
  219.        not ((abline < (Zeilen - bis + von)) or (Y < bis)) then
  220.     begin
  221.       Merk := Zeilen;
  222.       Array_updaten(Ka);
  223.       abline := abline - (K[Ka]^.NeueZeilen - (Zeilen-Merk));
  224.       K[Ka]^.ScrZlnMerk := Word(K[Ka]^.ScrZlnMerk + K[Ka]^.NeueZeilen);
  225.       K[Ka]^.NeueZeilen := 0;
  226.  
  227.       if (abline < 1) and (Zeilen > bis - von) then
  228.       begin
  229.         abline := 1;
  230.         Y := von;
  231.         Zeig(Ka,von,bis,abline);
  232.         Flag := true;
  233.       end;
  234.     end;
  235.  
  236.     If (abline + (Y-von) < Zeilen) and not Flag then
  237.     begin
  238.       inc(Y);
  239.       if Y > bis then
  240.       begin
  241.         Y := bis;
  242.         inc(abline);
  243.         Scroll(Up,1,von,bis);
  244.       end;
  245.       Zeig(Ka,Y-1,Y,abline + (Y-1) - von);
  246.     end;
  247.   End;
  248.  
  249.   Procedure NewBild;
  250.   Begin
  251.     if abline > 0 then Zeig(Kanal,von,bis,abline)
  252.                   else Zeig(Kanal,Y,bis,abline + Y-von);
  253.   End;
  254.  
  255.   Procedure CancelBlock;
  256.   Begin
  257.     if MarkBlock then
  258.     begin
  259.       FreeMem(BlAttr,Zeilen);
  260.       MarkBlock := false;
  261.       StartPage := 0;
  262.       StopPage := 0;
  263.       Cursor_aus;
  264.     end;
  265.     NewBild;
  266.   End;
  267.  
  268. Begin
  269.   with K[Kanal]^ do
  270.   begin
  271.     Nx := (NrStat[2]-1) * 20 + 1;
  272.     ScrZlnMerk := Word(ScrZlnMerk + NeueZeilen);
  273.     NeueZeilen := 0;
  274.     Neu_Bild;
  275.     RetFlag := false;
  276.     VorEdit := false;
  277.     QsoScroll := true;
  278.     CurObStat := false;
  279.     MarkBlock := false;
  280.     NowBlock := false;
  281.     NowZlnMerk := false;
  282.     StartPage := 0;
  283.     StopPage := 0;
  284.     XB := 1;
  285.     if Braille80 then X := 80 else X := 1;
  286.     Zeilen := 0;
  287.     RET := Nil;
  288.     Page := Nil;
  289.     GetMem(RET,maxNotLines*2);
  290.     FillChar(RET^,SizeOf(RET^),0);
  291.     GetMem(Page,maxNotCh);
  292.  
  293.     Array_updaten(Kanal);
  294.  
  295.     if Kanal > 0 then
  296.     begin
  297.       von := QBeg;   bis := QEnd;
  298.     end else
  299.     begin
  300.       von := UnStat + 1;   bis := maxZ;
  301.     end;
  302.     abline := Zeilen - (bis - von);
  303.     Y := bis;
  304.     Zeig(Kanal,Y,Y,abline + Y - von);
  305.     WriteAttr(1,Y,80,Attrib[4],1);
  306.     Fertig := false;
  307.     SuchStr := '';
  308.  
  309. Nochmal:
  310.  
  311.     WriteRam(Nx+1,ObStat,Attrib[9],1,ConstStr(B1,19));
  312.     Repeat
  313.       i := ((Zeilen + 1) - abline) - (Y - von);
  314.       i1 := abline + (Y-von);
  315.       if MarkBlock then BlStr := S_ch
  316.                    else BlStr := B1;
  317.       if MarkBlock and BlAttr^[i1] then
  318.       begin
  319.         BlStr := '■' + BlStr;
  320.         if not NowBlock and BlTon then Beep(G^.BLockAnfFreq,G^.BlockPiep1Time);
  321.         NowBlock := true;
  322.       end else
  323.       begin
  324.         BlStr := B1 + BlStr;
  325.         if NowBlock and BlTon then Beep(G^.BLockEndFreq,G^.BlockPiep2Time);
  326.         NowBlock := false;
  327.       end;
  328.       abLineStr := SFillStr(4,B1,int_str(i)) + '/' + int_str(Zeilen) + BlStr;
  329.       WriteRam(Nx+1,ObStat,Attrib[9],1,EFillStr(9,B1,ablineStr));
  330.       if HardCur and not VorEdit then
  331.       begin
  332.         if CurObStat then SetzeCursor(X,ObStat)
  333.                      else SetzeCursor(X,Y);
  334.       end else if MarkBlock then SetzeCursor(XB,Y);
  335.  
  336.       Repeat
  337.         if TimerTick > PollTime then
  338.         begin
  339.           Uhr_aus;
  340.           WriteRam(Nx+12,ObStat,Attrib[9],1,EFillStr(8,B1,LRK + int_str(NeueZeilen) + RRK));
  341.           TNCs_Pollen;
  342.           if notScroll then
  343.           begin
  344.             notScroll := false;
  345.             if abline > 0 then Zeig(Kanal,von,bis,abline)
  346.                           else Zeig(Kanal,Y,bis,abline + Y-von);
  347.           end;
  348.         end;
  349.       Until _KeyPressed;
  350.       _ReadKey(KC,VC);
  351.       PollTime := TimerTick + KeyDelay;
  352.  
  353.       if VorEdit then
  354.       begin
  355.         if KC in [_Esc,_PgUp,_Alt0,_F11] then
  356.         begin
  357.           VorEdit := false;
  358.           Zeig(Kanal,Y,Y,abline + Y-von);
  359.         end else
  360.         if KC in [_AltA.._AltY,_AltZ,_Home,_ShIns,_ShTab,_End,_Ins.._Ret,_Back,_Nix]
  361.          then Key_Active(Kanal,KC,VC)
  362.          else Alarm;
  363.       end else
  364.       case KC of
  365.          _Up : CursorUp(Kanal);
  366.  
  367.          _Dn : CursorDown(Kanal);
  368.  
  369.        _Home : begin
  370.                  if ScrZlnMerk >= Zeilen then ScrZlnMerk := Zeilen - 1;
  371.                  if ScrZlnMerk > (bis - von) then Y := von
  372.                                              else Y := bis - ScrZlnMerk;
  373.                  i := abline;
  374.                  abline := Zeilen - ScrZlnMerk + von - Y;
  375.                  if abline > 0 then Zeig(Kanal,von,bis,abline) else
  376.                  begin
  377.                    abline := i;
  378.                    Y := bis - ScrZlnMerk + 1;
  379.                    if Y > bis then Y := bis;
  380.                    Zeig(Kanal,Y,bis,abline + Y - von);
  381.                  end;
  382.                end;
  383.  
  384.        _End  : begin
  385.                  ScrZlnMerk := Word(Zeilen - abline - Y + von);
  386.                  NowZlnMerk := true;
  387.                end;
  388.  
  389.        _PgUp : begin        { Page up     }
  390.                  if abline > 0 then
  391.                  begin
  392.                    abline := abline - (bis-von);
  393.                    if HardCur then Y := von + 1;
  394.                    if abline <= 0 then
  395.                    begin
  396.                      abline := 1;
  397.                      Y := von;
  398.                    end;
  399.                    Zeig(Kanal,von,bis,abline);
  400.                  end else
  401.                  begin
  402.                    Y := bis - Zeilen + 1;
  403.                    Zeig(Kanal,Y,bis,abline + Y-von);
  404.                  end;
  405.                end;
  406.  
  407.        _PgDn : begin        { Page down   }
  408.                  PFlag := false;
  409.                  if (NeueZeilen > 0) and not MarkBlock and
  410.                     (abline + bis - von > Zeilen - bis + von) then
  411.                  begin
  412.                    i := Zeilen;
  413.                    Array_updaten(Kanal);
  414.                    abline := abline - (NeueZeilen - (Zeilen-i));
  415.                    ScrZlnMerk := Word(ScrZlnMerk + NeueZeilen);
  416.                    NeueZeilen := 0;
  417.  
  418.                    if (abline < 1) and (Zeilen > bis - von) then
  419.                    begin
  420.                      abline := 1;
  421.                      Y := von;
  422.                      Zeig(Kanal,von,bis,abline);
  423.                      PFlag := true;
  424.                    end;
  425.                  end;
  426.  
  427.                  if not PFlag then if abline > 0 then
  428.                  begin
  429.                    abline := abline + (bis-von);
  430.                    if HardCur then Y := von + 1;
  431.                    if abline > (Zeilen - (bis - von)) then
  432.                    begin
  433.                      abLine := Zeilen - (bis - von);
  434.                      Y := bis;
  435.                    end;
  436.                    Zeig(Kanal,von,bis,abline);
  437.                  end else
  438.                  begin
  439.                    Y := bis;
  440.                    Zeig(Kanal,Y-Zeilen+1,Y,1);
  441.                  end;
  442.                end;
  443.  
  444.    _CtrlPgUp : begin
  445.                  if abline > 0 then
  446.                  begin
  447.                    abline := 1;
  448.                    Y := von;
  449.                    Zeig(Kanal,von,bis,abline);
  450.                  end else
  451.                  begin
  452.                    Y := bis - Zeilen + 1;
  453.                    Zeig(Kanal,Y,bis,abline + Y-von);
  454.                  end;
  455.                end;
  456.  
  457.    _CtrlPgDn : begin
  458.                  if abline > 0 then
  459.                  begin
  460.                    abLine := Zeilen - (bis - von);
  461.                    Y := bis;
  462.                    Zeig(Kanal,von,bis,abline);
  463.                  end else
  464.                  begin
  465.                    Y := bis;
  466.                    Zeig(Kanal,Y-Zeilen+1,Y,1);
  467.                  end;
  468.                end;
  469.  
  470.    _CtrlHome : begin
  471.                  if abline > 0 then
  472.                  begin
  473.                    Y := von;
  474.                    Zeig(Kanal,von,bis,abline);
  475.                  end else
  476.                  begin
  477.                    Y := bis - Zeilen + 1;
  478.                    Zeig(Kanal,Y,bis,abline + Y-von);
  479.                  end;
  480.                end;
  481.  
  482.     _CtrlEnd : begin
  483.                  if abline > 0 then
  484.                  begin
  485.                    Y := bis;
  486.                    Zeig(Kanal,von,bis,abline);
  487.                  end else
  488.                  begin
  489.                    Y := bis;
  490.                    Zeig(Kanal,Y-Zeilen+1,Y,1);
  491.                  end;
  492.                end;
  493.  
  494.        _ShUp : if abline + (Y-von) > 1 then
  495.                begin
  496.                  GetRam;
  497.                  if BlAttr^[abline + (Y-von)] then
  498.                  begin
  499.                    BlAttr^[abline + (Y-von)] := false;
  500.                  end else
  501.                  if BlAttr^[abline + (Y-von)-1] then
  502.                  begin
  503.                    BlAttr^[abline + (Y-von)-1] := false;
  504.                  end else BlAttr^[abline + (Y-von)] := true;
  505.                  CursorUp(Kanal);
  506.                end;
  507.  
  508.        _ShDn : if abline + (Y-von) < Zeilen then
  509.                begin
  510.                  GetRam;
  511.                  if BlAttr^[abline + (Y-von)] then
  512.                  begin
  513.                    BlAttr^[abline + (Y-von)] := false;
  514.                  end else
  515.                  if BlAttr^[abline + (Y-von)+1] then
  516.                  begin
  517.                    BlAttr^[abline + (Y-von)+1] := false;
  518.                  end else BlAttr^[abline + (Y-von)] := true;
  519.                  CursorDown(Kanal);
  520.                end;
  521.  
  522.     _ShRight : begin
  523.                  GetRam;
  524.                  BlAttr^[abline + (Y-von)] := not BlAttr^[abline + (Y-von)];
  525.                  Zeig(Kanal,Y,Y,abline + Y-von);
  526.                end;
  527.  
  528.        _Alt1 : StartPage := abline + (Y-von);
  529.  
  530.        _Alt2 : if StartPage > 0 then
  531.                begin
  532.                  GetRam;
  533.                  StopPage := abline + (Y-von);
  534.                  if StartPage > StopPage then
  535.                  begin
  536.                    i := StopPage;
  537.                    StopPage := StartPage;
  538.                    StartPage := i;
  539.                  end;
  540.                  for i := StartPage to StopPage do BlAttr^[i] := true;
  541.                  StartPage := 0;
  542.                  NewBild;
  543.                end else Alarm;
  544.  
  545.      _AltF, _AltN :
  546.                If ((Zeilen + 1) - abline) - (Y - von) > 1 then
  547.                begin
  548.                  if (KC = _AltN) and (Suchstr > '') then goto Nochmal1;
  549.                  WriteRam(1,Y,Attrib[4],1,EFillStr(80,B1,InfoZeile(7)));
  550.                  GetString(Suchstr,Attrib[4],30,45,Y,KC,0,Ins);
  551.                  if KC <> _Esc then
  552.                  begin
  553.        Nochmal1:
  554.                    i := abline + (Y-von) +1;
  555.                    gefunden := false;
  556.                    Repeat
  557.                      gefunden := pos(Suchstr,UpCaseStr(BringZeile(Kanal,i))) > 0;
  558.                      inc(i);
  559.                    Until gefunden or (i > Zeilen);
  560.                    if gefunden then
  561.                    begin
  562.                      if (i > Zeilen - (bis - von)) and ((Zeilen-i) < (bis-Y)) then
  563.                      begin
  564.                        abline := Zeilen - (bis - von);
  565.                        Y := ((i - abline) + von) - 1;
  566.                      end else  abline := (i - Y) + (von - 1);
  567.                      if abline > 0 then Zeig(Kanal,von,bis,abline)
  568.                                    else Zeig(Kanal,Y,bis,abline + Y-von);
  569.                      if Klingel then Beep(1500,30);
  570.                    end else
  571.                    begin
  572.                      Teil_Bild_Loesch(Y,Y,Attrib[4]);
  573.                      WriteRam(10,Y,Attrib[4],1,InfoZeile(9));
  574.                      Alarm;
  575.                      Verzoegern(ZWEI);
  576.                    end;
  577.                  end;
  578.                  if abline > 0 then Zeig(Kanal,von,bis,abline)
  579.                                else Zeig(Kanal,bis-Zeilen+1,bis,1);
  580.                  VC := #255;
  581.                  goto Nochmal;
  582.                end else Alarm;
  583.  
  584.        _Ret,
  585.        _AltZ : if Zeilen > 1 then
  586.                begin
  587.                  if KC = _AltZ then Zstr := '> ' else Zstr := '';
  588.                  if Vor_im_EMS then EMS_Seite_einblenden(Kanal,Vor);
  589.                  if RetFlag then Chr_Vor_Show(Kanal,_Alt7,#255);
  590.                  VorWrite[Kanal]^[stV] := Zstr + BringZeile(Kanal,abline + (Y-von));
  591.                  Chr_Vor_Show(Kanal,_End,#255);
  592.                  RetFlag := true;
  593.                  CursorDown(Kanal);
  594.                  goto Nochmal;
  595.                end else Alarm;
  596.  
  597.        _AltG : begin
  598.                  SysopParm := true;
  599.                  PassRetry := 1;
  600.                  PassRight := 1;
  601.                  SysopArt := LRK + CutStr(User_Name) + RRK;
  602.                  MoStr := BringZeile(Kanal,abline + (Y-von));
  603.                  if pos(RSK,MoStr) = 0 then MoStr := RSK + MoStr;
  604.                  Password_Auswert(Kanal,MoStr + M1);
  605.                end;
  606.  
  607.        _AltH : TOP_Help(G^.OHelp[19]);
  608.  
  609.        _AltM : if Kanal = 0 then
  610.                begin
  611.                  MoStr := BringZeile(Kanal,abline + (Y-von));
  612.  
  613.                  i := pos(LRK,MoStr);
  614.                  i1 := pos(LRK + B1,MoStr);
  615.                  if (i = 1) and (i1 = 4) then delete(MoStr,1,5);
  616.  
  617.                  i := pos(fm,MoStr);
  618.                  i1 := pos(zu,MoStr);
  619.                  if (i > 0) and (i1 > i) then
  620.                  begin
  621.                    delete(MoStr,i1,3);
  622.                    delete(MoStr,1,i+2);
  623.                  end;
  624.  
  625.                  i := pos(DP,MoStr);
  626.                  if i = 2 then delete(MoStr,1,2);
  627.  
  628.                  i := pos(RSK,MoStr);
  629.                  if i <= 10 then MoStr[i] := B1;
  630.                  FreeMonitorKanal(b,ParmStr(1,B1,MoStr) + B1 + ParmStr(2,B1,MoStr));
  631.                  if b > 0 then
  632.                  begin
  633.                    Calls_Monitoren(b,ParmStr(1,B1,MoStr) + B1 + ParmStr(2,B1,MoStr));
  634.                    if abline > 0 then Zeig(Kanal,von,bis,abline)
  635.                                  else Zeig(Kanal,bis-Zeilen+1,bis,1);
  636.                  end else Alarm;
  637.                end else Alarm;
  638.  
  639.        _AltP : begin
  640.                  if LPT_vorhanden and Lpt_All_Ok(PrtPort) then
  641.                  begin
  642.                    YScrolPos := Y;
  643.                    if MarkBlock then
  644.                    begin
  645.                      for i := 1 to Zeilen do if BlAttr^[i] and not PrtFailure then
  646.                       Write_Drucker(Kanal,Eig(i) + BringZeile(Kanal,i) + M1);
  647.                      CancelBlock;
  648.                    end else for i := abline + (Y-von) to Zeilen do
  649.                     if not PrtFailure
  650.                      then Write_Drucker(Kanal,Eig(i) + BringZeile(Kanal,i) + M1);
  651.                  end else
  652.                  begin
  653.                    WriteRam(1,Y,Attrib[4],1,EFillStr(80,B1,InfoZeile(290)));
  654.                    Alarm;
  655.                    Verzoegern(ZWEI);
  656.                  end;
  657.                  Zeig(Kanal,Y,Y,abline + Y-von);
  658.                  VC := #255;
  659.                  goto Nochmal;
  660.                end;
  661.  
  662.        _AltS : Begin   { Saven }
  663.                  WriteRam(1,Y,Attrib[4],1,EFillStr(80,B1,B1+InfoZeile(142)+B1));
  664.                  Save_Name := G^.SavePfad + 'SCR.'+ SFillStr(3,'0',int_str(Kanal));
  665.                  GetString(Save_Name,Attrib[4],60,9,Y,KC,1,Ins);
  666.                  if KC <> _Esc then
  667.                  begin
  668.                    Assign(NSave,Save_Name);
  669.                    Result := AppendTxt(NSave);
  670.                    if Result <> 0 then Result := RewriteTxt(NSave);
  671.                    if Result = 0 then
  672.                    begin
  673.                      if MarkBlock then
  674.                      begin
  675.                        for i := 1 to Zeilen do
  676.                         if BlAttr^[i] then Writeln(NSave,Eig(i),BringZeile(Kanal,i));
  677.                        CancelBlock;
  678.                      end else for i := abline + (Y-von) to Zeilen do
  679.                                        Writeln(NSave,Eig(i),BringZeile(Kanal,i));
  680.                      FiResult := CloseTxt(NSave);
  681.                    end else
  682.                    begin
  683.                      WriteRam(1,Y,Attrib[4],1,EFillStr(80,B1,B1 +
  684.                                   InfoZeile(75) + DP + B2 + Save_Name));
  685.                      Alarm;
  686.                      Verzoegern(ZWEI);
  687.                    end;
  688.                  end;
  689.                  VC := #255;
  690.                  Zeig(Kanal,Y,Y,abline + Y-von);
  691.                end;
  692.  
  693.       _ShTab : begin
  694.                  CurObStat := not CurObStat;
  695.                  if CurObStat then X := ((NrStat[2]-1)*20)+1 else X := 80;
  696.                end;
  697.  
  698.      _Tab    : CancelBlock;
  699.  
  700.      _Ins    : begin
  701.                  VorEdit := true;
  702.                  WriteRam(1,Y,Attrib[4],1,ConstStr(#24,80));
  703.                  Chr_Vor_Show(Kanal,_Nix,#255);
  704.                end;
  705.  
  706.    _F1.._F10,
  707.    _F12      : begin
  708.                  ch_aus := true;
  709.                  SK_out := KC;
  710.                  VC_out := VC;
  711.                  Fertig := true;
  712.                end;
  713.  
  714.         _Del, _Esc
  715.              : Fertig := true;
  716.  
  717.      _Andere : Alarm;
  718.         else Alarm;
  719.       end;      (* case *)
  720.     Until Fertig;
  721.     if MarkBlock then FreeMem(BlAttr,Zeilen);
  722.     if ZlnMerk and not NowZlnMerk then ScrZlnMerk := Word(Zeilen - abline - Y + von);
  723.     FreeMem(Page,maxNotCh);
  724.     FreeMem(RET,maxNotLines*2);
  725.     QsoScroll := false;
  726.     Cursor_aus;
  727.     if HardCur then JumpRxScr := true;
  728.     Neu_Bild;
  729.   end;
  730. End;
  731.  
  732.  
  733. Procedure FileScroll (* Kanal : Byte *);
  734. var     KC        : Sondertaste;
  735.         VC,
  736.         Hch       : Char;
  737.         Lines     : ^MbxTypPtr;
  738.         A,X,Y,
  739.         maxY,
  740.         minY,
  741.         Nx,
  742.         Attr,
  743.         XMerk,
  744.         Spalte,
  745.         AnzSp,
  746.         Yofs      : Byte;
  747.         maxL,
  748.         Result    : Word;
  749.         i,i1,
  750.         Lpos,
  751.         Fpos,
  752.         MFpos,
  753.         FSize,
  754.         Zmax,
  755.         MmaxL     : LongInt;
  756.         HLstr     : MbxZeile;
  757.         Bstr,
  758.         Hstr      : String[80];
  759.         Save_Name : String[60];
  760.         SuchStr   : String[30];
  761.         Ende,
  762.         Found,
  763.         update,
  764.         RetFlag,
  765.         New_Lines,
  766.         CurObStat,
  767.         UpScroll,
  768.         Fail,
  769.         VorEdit,
  770.         First     : Boolean;
  771.         BoxSave   : Text;
  772.  
  773.  
  774.   Function  MakeStr(Zeile : MbxZeile; Art : Byte; var Col : Byte) : StrBox;
  775.   var   Hstr : String[BoxRec];
  776.   Begin
  777.     move(Zeile,Hstr[1],BoxRec);
  778.     Hstr[0] := Chr(BoxRec);
  779.     Col := Ord(Hstr[81]);
  780.     case Art of
  781.       0 : Hstr[0] := Chr(80);
  782.       1 : delete(Hstr,1,83);
  783.       2 : Hstr := copy(Hstr,82,2);
  784.     end;
  785.     MakeStr := Hstr;
  786.   End;
  787.  
  788.   Procedure DoPage(von,bis : Byte);
  789.   var  i,i1 : LongInt;
  790.        Hstr : String[80];
  791.   begin
  792.     i1 := Lpos - Y + von;
  793.     for i := von to bis do
  794.     begin
  795.       Hstr := MakeStr(Lines^[i1],0,Attr);
  796.       WriteRam(1,i+Yofs,Attr,1,Hstr);
  797.       inc(i1);
  798.     end;
  799.   end;
  800.  
  801.   Procedure Updaten(Kanal : Byte);
  802.   var  l : LongInt;
  803.   Begin
  804.     with K[Kanal]^ do
  805.     begin
  806.       Seek(DBox,MFpos);
  807.       for l := 1 to MmaxL do BlockWrite(DBox,Lines^[l],1,Result);
  808.       update := false;
  809.     end;
  810.   End;
  811.  
  812.   Procedure HoleLines(Kanal : Byte; Stelle : LongInt);
  813.   var   l      : LongInt;
  814.         Result : Word;
  815.   Begin
  816.     with K[Kanal]^ do
  817.     begin
  818.       if update then Updaten(Kanal);
  819.       FillChar(Lines^,SizeOf(Lines^),0);
  820.       l := 1;
  821.       Seek(DBox,Stelle);
  822.       While not Eof(DBox) and (l <= maxL) do
  823.       begin
  824.         BlockRead(DBox,Lines^[l],1,Result);
  825.         inc(l);
  826.       end;
  827.       MFpos := Stelle;
  828.       MmaxL := maxL;
  829.     end;
  830.   End;
  831.  
  832.   Procedure CursorDown(Kanal : Byte);
  833.   Begin
  834.     with K[Kanal]^ do
  835.     begin
  836.       if (Fpos + Lpos) < FSize then
  837.       begin
  838.         DoPage(Y,Y);
  839.         if Lpos < maxL then inc(Lpos) else
  840.         begin
  841.           Fpos := Fpos + maxL - Zmax + 1;
  842.           Lpos := Zmax;
  843.           if Fpos + maxL > FSize then
  844.           begin
  845.             Lpos := maxL + Fpos + Zmax - FSize;
  846.             Fpos := FSize - maxL;
  847.           end;
  848.           HoleLines(Kanal,Fpos);
  849.         end;
  850.         if Y < Zmax then inc(Y) else
  851.         begin
  852.           Scroll(Up,1,minY,maxY);
  853.           DoPage(Y,Y);
  854.         end;
  855.       end else Alarm;
  856.     end;
  857.   End;
  858.  
  859.   Procedure CursorUp(Kanal : Byte);
  860.   Begin
  861.     with K[Kanal]^ do
  862.     begin
  863.       if (Fpos + Lpos > 1) then
  864.       begin
  865.         DoPage(Y,Y);
  866.         if Lpos > 1 then dec(Lpos) else
  867.         begin
  868.           Fpos := Fpos - maxL + Zmax - 1;
  869.           Lpos := maxL - Zmax + 1;
  870.           if Fpos < 0 then
  871.           begin
  872.             Lpos := Fpos + 1 - Zmax + maxL;
  873.             Fpos := 0;
  874.           end;
  875.           HoleLines(Kanal,Fpos);
  876.         end;
  877.         if Y > 1 then dec(Y) else
  878.         begin
  879.           Scroll(Dn,1,minY,maxY);
  880.           DoPage(Y,Y);
  881.         end;
  882.       end else Alarm;
  883.     end;
  884.   End;
  885.  
  886.   Procedure MakeRead(Kanal,Art : Byte; var FFlag : Boolean);
  887.   var   VwStr  : String[80];
  888.         Nstr   : String[12];
  889.         RubStr : String[12];
  890.         Astr   : String[2];
  891.         Typ,
  892.         A,b    : Byte;
  893.  
  894.     Procedure MakeTransfer;
  895.     Begin
  896.       VwStr := TrStr + B1 + RubStr + B1 + Nstr + B1;
  897.       if Typ in [1,14] then VwStr := VwStr + RSK + B1;
  898.       WriteRam(1,Y+Yofs,Attrib[4],1,ConstStr(B1,80));
  899.       GetString(VwStr,Attrib[4],60,2,Y+Yofs,KC,3,Ins);
  900.       if KC <> _Esc then
  901.       begin
  902.         Lines^[Lpos][b] := RepCh;
  903.         A := Attrib[19];
  904.       end else FFlag := true;
  905.     End;
  906.  
  907.   Begin
  908.     with K[Kanal]^ do
  909.     begin
  910.       VwStr := '';
  911.       FFlag := false;
  912.       b := 80;
  913.       Hstr := MakeStr(Lines^[Lpos],0,Attr);
  914.       Astr := MakeStr(Lines^[Lpos],2,Attr);
  915.       Typ := Ord(Astr[2]);
  916.  
  917.       case Typ of
  918.         1: begin (* DBOX *)
  919.              case Astr[1] of
  920.               'C': begin  (* CHECK-Eintrag *)
  921.                      RubStr := MakeStr(Lines^[Lpos],1,Attr);
  922.                      KillEndBlanks(Rubstr);
  923.                      Nstr := ParmStr(4,B1,Hstr);
  924.                      if length(Nstr) > 8 then
  925.                      begin
  926.                        Nstr := copy(Nstr,9,4);
  927.                        While copy(Nstr,1,1) = Pkt do delete(Nstr,1,1);
  928.                      end else Nstr := ParmStr(1,B1,Hstr);
  929.  
  930.                      case Art of
  931.                        0: begin  (* R ABC X *)
  932.                             A := Attrib[19];
  933.                             VwStr := ReadStr + B1 + RubStr + B1 + Nstr;
  934.                             Lines^[Lpos][b] := ReadCh;
  935.                           end;
  936.                        1: begin (* E ABC X *)
  937.                             A := Attrib[20];
  938.                             VwStr := EraseStr + B1 + RubStr + B1 + Nstr;
  939.                             Lines^[Lpos][b] := EraseCh;
  940.                           end;
  941.                        2: begin (* SETL ABC X #Y *)
  942.                             A := Attrib[20];
  943.                             VwStr := SetStr + B1 + RubStr + B1 + Nstr +
  944.                                      B1 + LZ + int_str(G^.SETL[SETNr]);
  945.                             Lines^[Lpos][b] := SetCh;
  946.                           end;
  947.                        7: begin  (* REP ABC X *)
  948.                             A := Attrib[19];
  949.                             VwStr := RepStr + B1 + RubStr + B1 + Nstr;
  950.                             Lines^[Lpos][b] := RepCh;
  951.                           end;
  952.                       11: begin  (* TR ABC X > ... *)
  953.                             MakeTransfer;
  954.                           end;
  955.                        else FFlag := true;
  956.                      end;
  957.                    end;
  958.               'L': begin  (* LIST-Eintrag *)
  959.                      RubStr := MakeStr(Lines^[Lpos],1,Attr);
  960.                      KillEndBlanks(RubStr);
  961.                      Nstr := ParmStr(1,B1,Hstr);
  962.                      case Art of
  963.                        0: begin  (* R ABC X *)
  964.                             A := Attrib[19];
  965.                             VwStr := ReadStr + B1 + RubStr + B1 + Nstr;
  966.                             Lines^[Lpos][b] := ReadCh;
  967.                           end;
  968.                        1: begin  (* E ABC X *)
  969.                             A := Attrib[20];
  970.                             VwStr := EraseStr + B1 + RubStr + B1 + Nstr;
  971.                             Lines^[Lpos][b] := EraseCh;
  972.                           end;
  973.                        2: begin  (* SETL ABC X #Y *)
  974.                             A := Attrib[20];
  975.                             VwStr := SetStr + B1 + RubStr + B1 + Nstr +
  976.                                      B1 + LZ + int_str(G^.SETL[SETNr]);
  977.                             Lines^[Lpos][b] := SetCh;
  978.                           end;
  979.                        7: begin  (* REP ABC X *)
  980.                             A := Attrib[19];
  981.                             VwStr := RepStr + B1 + RubStr + B1 + Nstr;
  982.                             Lines^[Lpos][b] := RepCh;
  983.                           end;
  984.                       11: begin  (* TR ABC X > ... *)
  985.                             MakeTransfer;
  986.                           end;
  987.                        else FFlag := true;
  988.                      end;
  989.                    end;
  990.               'R': begin  (* EL-Einträge, Dateien *)
  991.                      case Art of
  992.                        4 : VwStr := BinStr;  (* EL B *)
  993.                        5 : VwStr := BsStr;   (* EL BS *)
  994.                        6 : VwStr := PlusStr; (* EL 7 *)
  995.                       else VwStr := Readstr; (* EL R *)
  996.                      end;
  997.                      A := Attrib[19];
  998.                      VwStr := RunStr + B1 + ElStr + B1 + VwStr + B1 + ParmStr(1,B1,Hstr);
  999.                      Lines^[Lpos][b] := ReadCh;
  1000.                    end;
  1001.               'V': begin  (* EL-Einträge, Verzeichnisse *)
  1002.                      A := Attrib[19];
  1003.                      VwStr := RunStr + B1 + ElStr + B1 + DirStr + B1 + CutStr(Hstr); (* EL D *)
  1004.                      Lines^[Lpos][b] := ReadCh;
  1005.                    end;
  1006.               else FFlag := true;
  1007.              end;
  1008.            end;
  1009.  
  1010.         2: begin (* BBOX *)
  1011.              case Astr[1] of
  1012.               'C': begin  (* CHECK-Eintrag *)
  1013.                      RubStr := MakeStr(Lines^[Lpos],1,Attr);
  1014.                      KillEndBlanks(Rubstr);
  1015.                      Nstr := ParmStr(4,B1,Hstr);
  1016.                      if length(Nstr) > 8 then
  1017.                      begin
  1018.                        Nstr := copy(Nstr,9,4);
  1019.                        While copy(Nstr,1,1) = Pkt do delete(Nstr,1,1);
  1020.                      end else Nstr := ParmStr(1,B1,Hstr);
  1021.  
  1022.                      case Art of
  1023.                        0: begin  (* R ABC X *)
  1024.                             A := Attrib[19];
  1025.                             VwStr := ReadStr + B1 + RubStr + B1 + Nstr;
  1026.                             Lines^[Lpos][b] := ReadCh;
  1027.                           end;
  1028.                        1: begin (* E ABC X *)
  1029.                             A := Attrib[20];
  1030.                             VwStr := EraseStr + B1 + RubStr + B1 + Nstr;
  1031.                             Lines^[Lpos][b] := EraseCh;
  1032.                           end;
  1033.                        2: begin (* SETL ABC X #Y *)
  1034.                             A := Attrib[20];
  1035.                             VwStr := SetStr + B1 + RubStr + B1 + Nstr +
  1036.                                      B1 + LZ + int_str(G^.SETL[SETNr]);
  1037.                             Lines^[Lpos][b] := SetCh;
  1038.                           end;
  1039.                        7: begin  (* REP ABC X *)
  1040.                             A := Attrib[19];
  1041.                             VwStr := RepStr + B1 + RubStr + B1 + Nstr;
  1042.                             Lines^[Lpos][b] := RepCh;
  1043.                           end;
  1044.                        9: begin  (* K ABC X *)
  1045.                             A := Attrib[19];
  1046.                             VwStr := KbStr + B1 + RubStr + B1 + Nstr;
  1047.                             Lines^[Lpos][b] := KbCh;
  1048.                           end;
  1049.                       11: begin  (* TR ABC X ... *)
  1050.                             MakeTransfer;
  1051.                           end;
  1052.                        else FFlag := true;
  1053.                      end;
  1054.                    end;
  1055.               'L': begin  (* LIST-Eintrag *)
  1056.                      RubStr := MakeStr(Lines^[Lpos],1,Attr);
  1057.                      KillEndBlanks(RubStr);
  1058.                      Nstr := ParmStr(1,B1,Hstr);
  1059.                      case Art of
  1060.                        0: begin  (* R ABC X *)
  1061.                             A := Attrib[19];
  1062.                             VwStr := ReadStr + B1 + RubStr + B1 + Nstr;
  1063.                             Lines^[Lpos][b] := ReadCh;
  1064.                           end;
  1065.                        1: begin  (* E ABC X *)
  1066.                             A := Attrib[20];
  1067.                             VwStr := EraseStr + B1 + RubStr + B1 + Nstr;
  1068.                             Lines^[Lpos][b] := EraseCh;
  1069.                           end;
  1070.                        2: begin  (* SETL ABC X #Y *)
  1071.                             A := Attrib[20];
  1072.                             VwStr := SetStr + B1 + RubStr + B1 + Nstr +
  1073.                                      B1 + LZ + int_str(G^.SETL[SETNr]);
  1074.                             Lines^[Lpos][b] := SetCh;
  1075.                           end;
  1076.                        7: begin  (* REP ABC X *)
  1077.                             A := Attrib[19];
  1078.                             VwStr := RepStr + B1 + RubStr + B1 + Nstr;
  1079.                             Lines^[Lpos][b] := RepCh;
  1080.                           end;
  1081.                        9: begin  (* K ABC X *)
  1082.                             A := Attrib[19];
  1083.                             VwStr := KbStr + B1 + RubStr + B1 + Nstr;
  1084.                             Lines^[Lpos][b] := KbCh;
  1085.                           end;
  1086.                       11: begin  (* TR ABC X ... *)
  1087.                             MakeTransfer;
  1088.                           end;
  1089.                        else FFlag := true;
  1090.                      end;
  1091.                    end;
  1092.               'R': begin  (* EL-Einträge, Dateien *)
  1093.                      case Art of
  1094.                        4 : VwStr := BinStr;  (* EL B *)
  1095.                        5 : VwStr := BsStr;   (* EL BS *)
  1096.                        6 : VwStr := PlusStr; (* EL 7 *)
  1097.                       else VwStr := Readstr; (* EL R *)
  1098.                      end;
  1099.                      A := Attrib[19];
  1100.                      VwStr := ElStr + B1 + VwStr + B1 + ParmStr(1,B1,Hstr);
  1101.                      Lines^[Lpos][b] := ReadCh;
  1102.                    end;
  1103.               'V': begin  (* EL-Einträge, Verzeichnisse *)
  1104.                      A := Attrib[19];
  1105.                      VwStr := ElStr + B1 + DirStr + B1 + CutStr(Hstr); (* EL D *)
  1106.                      Lines^[Lpos][b] := ReadCh;
  1107.                    end;
  1108.               else FFlag := true;
  1109.              end;
  1110.            end;
  1111.  
  1112.         3: begin (* FBOX *)
  1113.              case Astr[1] of
  1114.               'L': begin  (* LIST-Eintrag *)
  1115.                      KillStartBlanks(Hstr);
  1116.                      Nstr := ParmStr(1,B1,Hstr);
  1117.                      case Art of
  1118.                        0: begin  (* R XXX *)
  1119.                             A := Attrib[19];
  1120.                             VwStr := ReadStr + B1 + Nstr;
  1121.                             Lines^[Lpos][b] := ReadCh;
  1122.                           end;
  1123.                        1: begin (* K XXX *)
  1124.                             A := Attrib[20];
  1125.                             VwStr := KillStr + B1 + Nstr;
  1126.                             Lines^[Lpos][b] := EraseCh;
  1127.                           end;
  1128.                        else FFlag := true;
  1129.                      end;
  1130.                    end;
  1131.               else FFlag := true;
  1132.              end;
  1133.            end;
  1134.  
  1135.         4: begin (* WBOX *)
  1136.              case Astr[1] of
  1137.               'C': begin  (* CHECK-Eintrag *)
  1138.                      KillStartBlanks(Hstr);
  1139.                      Nstr := CutStr(Hstr);
  1140.                      case Art of
  1141.                        0: begin  (* R XXX *)
  1142.                             A := Attrib[19];
  1143.                             VwStr := ReadStr + B1 + Nstr;
  1144.                             Lines^[Lpos][b] := ReadCh;
  1145.                           end;
  1146.                        1: begin (* E XXX *)
  1147.                             A := Attrib[20];
  1148.                             VwStr := EraseStr + B1 + Nstr;
  1149.                             Lines^[Lpos][b] := EraseCh;
  1150.                           end;
  1151.                        else FFlag := true;
  1152.                      end;
  1153.                    end;
  1154.               else FFlag := true;
  1155.              end;
  1156.            end;
  1157.  
  1158.         5: begin (* EBOX *)
  1159.              case Astr[1] of
  1160.               'L': begin  (* LIST-Eintrag *)
  1161.                      KillStartBlanks(Hstr);
  1162.                      Nstr := CutStr(Hstr);
  1163.                      case Art of
  1164.                        0: begin (* R XXX *)  (* RB XXX *)
  1165.                             A := Attrib[19];
  1166.                             if UpCaseStr(ParmStr(8,B1,Hstr)) = 'D'
  1167.                              then VwStr := RBinStr + B1 + Nstr
  1168.                              else VwStr := ReadStr + B1 + Nstr;
  1169.                             Lines^[Lpos][b] := ReadCh;
  1170.                           end;
  1171.                        1: begin   (* K XXX *)
  1172.                             A := Attrib[20];
  1173.                             VwStr := KillStr + B1 + Nstr;
  1174.                             Lines^[Lpos][b] := EraseCh;
  1175.                           end;
  1176.                        8: begin   (* U XXX *)
  1177.                             A := Attrib[19];
  1178.                             VwStr := UnprStr + B1 + Nstr;
  1179.                             Lines^[Lpos][b] := ReadCh;
  1180.                           end;
  1181.                       10: begin   (* CRC XXX *)
  1182.                             A := Attrib[19];
  1183.                             VwStr := CrcStr + B1 + Nstr;
  1184.                             Lines^[Lpos][b] := ReadCh;
  1185.                           end;
  1186.                        else FFlag := true;
  1187.                      end;
  1188.                    end;
  1189.               else FFlag := true;
  1190.              end;
  1191.            end;
  1192.  
  1193.        14: begin (* TBOX *)
  1194.              case Astr[1] of
  1195.               'C': begin  (* CHECK-Eintrag *)
  1196.                      RubStr := MakeStr(Lines^[Lpos],1,Attr);
  1197.                      KillEndBlanks(Rubstr);
  1198.                      Nstr := ParmStr(4,B1,Hstr);
  1199.                      if length(Nstr) > 8 then
  1200.                      begin
  1201.                        Nstr := copy(Nstr,9,4);
  1202.                        While copy(Nstr,1,1) = Pkt do delete(Nstr,1,1);
  1203.                      end else Nstr := ParmStr(1,B1,Hstr);
  1204.  
  1205.                      case Art of
  1206.                        0: begin  (* R ABC X *)
  1207.                             A := Attrib[19];
  1208.                             VwStr := ReadStr + B1 + RubStr + B1 + Nstr;
  1209.                             Lines^[Lpos][b] := ReadCh;
  1210.                           end;
  1211.                        1: begin (* E ABC X *)
  1212.                             A := Attrib[20];
  1213.                             VwStr := EraseStr + B1 + RubStr + B1 + Nstr;
  1214.                             Lines^[Lpos][b] := EraseCh;
  1215.                           end;
  1216.                        2: begin (* SETL ABC X #Y *)
  1217.                             A := Attrib[20];
  1218.                             VwStr := SetStr + B1 + RubStr + B1 + Nstr +
  1219.                                      B1 + LZ + int_str(G^.SETL[SETNr]);
  1220.                             Lines^[Lpos][b] := SetCh;
  1221.                           end;
  1222.                        7: begin  (* REP ABC X *)
  1223.                             A := Attrib[19];
  1224.                             VwStr := RepStr + B1 + RubStr + B1 + Nstr;
  1225.                             Lines^[Lpos][b] := RepCh;
  1226.                           end;
  1227.                       11: begin  (* TR ABC X > ... *)
  1228.                             MakeTransfer;
  1229.                           end;
  1230.                        else FFlag := true;
  1231.                      end;
  1232.                    end;
  1233.               'L': begin  (* LIST-Eintrag *)
  1234.                      RubStr := MakeStr(Lines^[Lpos],1,Attr);
  1235.                      KillEndBlanks(RubStr);
  1236.                      Nstr := ParmStr(1,B1,Hstr);
  1237.                      case Art of
  1238.                        0: begin  (* R ABC X *)
  1239.                             A := Attrib[19];
  1240.                             VwStr := ReadStr + B1 + RubStr + B1 + Nstr;
  1241.                             Lines^[Lpos][b] := ReadCh;
  1242.                           end;
  1243.                        1: begin  (* E ABC X *)
  1244.                             A := Attrib[20];
  1245.                             VwStr := EraseStr + B1 + RubStr + B1 + Nstr;
  1246.                             Lines^[Lpos][b] := EraseCh;
  1247.                           end;
  1248.                        2: begin (* SETL ABC X #Y *)
  1249.                             A := Attrib[20];
  1250.                             VwStr := SetStr + B1 + RubStr + B1 + Nstr +
  1251.                                      B1 + LZ + int_str(G^.SETL[SETNr]);
  1252.                             Lines^[Lpos][b] := SetCh;
  1253.                           end;
  1254.                        7: begin  (* REP ABC X *)
  1255.                             A := Attrib[19];
  1256.                             VwStr := RepStr + B1 + RubStr + B1 + Nstr;
  1257.                             Lines^[Lpos][b] := RepCh;
  1258.                           end;
  1259.                       11: begin  (* TR ABC X > ... *)
  1260.                             MakeTransfer;
  1261.                           end;
  1262.                        else FFlag := true;
  1263.                      end;
  1264.                    end;
  1265.               else FFlag := true;
  1266.              end;
  1267.            end;
  1268.         else FFlag := true;
  1269.       end;
  1270.  
  1271.       if not FFlag then
  1272.       begin
  1273.         if not RetFlag then Chr_Vor_Show(Kanal,_Alt8,#255)
  1274.                        else Chr_Vor_Show(Kanal,_Andere,^J);
  1275.         VorWrite[Kanal]^[stV] := VwStr;
  1276.         update := true;
  1277.         Lines^[Lpos][81] := Chr(A);
  1278.         Chr_Vor_Show(Kanal,_End,#255);
  1279.         RetFlag := true;
  1280.         DoPage(1,Zmax);
  1281.       end;
  1282.     end;
  1283.   End;
  1284.  
  1285.   Function NoHeader(Zeile : MbxZeile) : Boolean;
  1286.   var  Attr : Byte;
  1287.   Begin
  1288.     NoHeader := pos('∙ ',MakeStr(Zeile,0,Attr)) <> 1;
  1289.   End;
  1290.  
  1291.  
  1292. Begin
  1293.   with K[Kanal]^ do
  1294.   begin
  1295.     Neu_Bild;
  1296.     if not ChkLstOpen then OpenDBox(Kanal);
  1297.     BoxScroll := true;
  1298.     if Vor_im_EMS then EMS_Seite_einblenden(Kanal,Vor);
  1299.     if Braille80 then X := 80 else X := 1;
  1300.     Y := 1;
  1301.     Ende := false;
  1302.     VorEdit := false;
  1303.     Nx := (NrStat[2]-1) * 20 + 1;
  1304.     Fpos := 0;
  1305.     Lpos := 1;
  1306.     SuchStr := '';
  1307.     CurObStat := false;
  1308.     First := true;
  1309.     New_Lines := false;
  1310.     update := false;
  1311.     RetFlag := false;
  1312.     UpScroll := false;
  1313.     Yofs := QBeg - 1;
  1314.     minY := QBeg;
  1315.     maxY := QEnd;
  1316.     Zmax := QEnd - QBeg + 1;
  1317.     Teil_Bild_Loesch(minY,maxY,Attrib[18]);
  1318.     KC := _CtrlPgDn;
  1319.     VC := #255;
  1320.  
  1321.     Repeat
  1322.       if not First then
  1323.       begin
  1324.         Repeat
  1325.           if TimerTick > PollTime then
  1326.           begin
  1327.             New_Lines := false;
  1328.             Uhr_aus;
  1329.             TNCs_Pollen;
  1330.             if (FSize <= (QEnd - QBeg + 5)) and (NewChkLst > 0) then New_Lines := true;
  1331.           end;
  1332.         Until New_Lines or _KeyPressed;
  1333.         if not New_Lines then _ReadKey(KC,VC);
  1334.       end;
  1335.       PollTime := TimerTick + KeyDelay;
  1336.  
  1337.       Fail := false;
  1338.  
  1339.       if FSize <= maxMbxLines then maxL := FSize
  1340.                               else maxL := maxMbxLines;
  1341.       if FSize <= Zmax then Zmax := FSize
  1342.                        else Zmax := QEnd - Yofs;
  1343.       if maxL <= Zmax then Zmax := maxL;
  1344.       maxY := Zmax + Yofs;
  1345.  
  1346.       if First then
  1347.       begin
  1348.         GetMem(Lines,SizeOf(Lines^));
  1349.         FillChar(Lines^,SizeOf(Lines^),0);
  1350.         if FSize = 0 then
  1351.         begin
  1352.           First := false;
  1353.           HoleLines(Kanal,0);
  1354.           DoPage(1,Zmax);
  1355.         end;
  1356.       end;
  1357.  
  1358.       if New_Lines then
  1359.       begin
  1360.         New_Lines := false;
  1361.         KC := _Tab;
  1362.       end;
  1363.  
  1364.       if NewChkLst > 0 then
  1365.       begin
  1366.         HoleLines(Kanal,Fpos);
  1367.         NewChkLst := 0;
  1368.       end;
  1369.  
  1370.       if VorEdit then
  1371.       begin
  1372.         if KC in [_Esc,_PgUp,_Alt0,_F11] then
  1373.         begin
  1374.           VorEdit := false;
  1375.           DoPage(Y,Y);
  1376.         end else
  1377.         if KC in [_AltA.._AltY,_AltZ,_Home,_ShIns, _ShTab,_End,_Ins.._Ret,_Back,_Nix]
  1378.          then Key_Active(Kanal,KC,VC)
  1379.          else Alarm;
  1380.       end else
  1381.       case KC of
  1382.       _Andere : begin
  1383.                   if UpCase(VC) in [' ','K','L','R','D','B','S','T','7','C','U'] then
  1384.                   begin
  1385.                     if NoHeader(Lines^[Lpos]) then
  1386.                     case UpCase(VC) of
  1387.                       ' ' : MakeRead(Kanal,0,Fail);  (* R... 123 *)
  1388.  
  1389.                       'T' : MakeRead(Kanal,11,Fail); (* TR IBM 123 *)
  1390.  
  1391.                       'K' : MakeRead(Kanal,9,Fail);  (* K IBM 123 *)
  1392.                       'L' : MakeRead(Kanal,2,Fail);  (* SETL IBM 123 *)
  1393.                       'R' : MakeRead(Kanal,7,Fail);  (* REP IBM 123 *)
  1394.  
  1395.                       'D' : MakeRead(Kanal,3,Fail);  (* EL D *)
  1396.                       'B' : MakeRead(Kanal,4,Fail);  (* EL B *)
  1397.                       'S' : MakeRead(Kanal,5,Fail);  (* EL BS *)
  1398.                       '7' : MakeRead(Kanal,6,Fail);  (* EL 7 *)
  1399.  
  1400.                       'C' : MakeRead(Kanal,10,Fail); (* CRC 12345 *)
  1401.                       'U' : MakeRead(Kanal,8,Fail);  (* U 12345 *)
  1402.                     end else Fail := true;
  1403.  
  1404.                     if not Fail then
  1405.                     begin
  1406.                       if UpScroll then CursorUp(Kanal)
  1407.                                   else CursorDown(Kanal);
  1408.                     end else
  1409.                     begin
  1410.                       Alarm;
  1411.                       DoPage(Y,Y);
  1412.                     end;
  1413.                   end else if (VC = ^Y) then
  1414.                   begin
  1415.                     FillChar(Lines^[Lpos],79,B1);
  1416.                     update := true;
  1417.                     DoPage(Y,Y);
  1418.                   end else Alarm;
  1419.                 end;
  1420.  
  1421.         _Back : begin
  1422.                   UpScroll := not UpScroll;
  1423.                   if UpScroll
  1424.                   then WriteRam(1,Y+Yofs,Attrib[4],1,EFillStr(80,B1,ConstStr(B1,20) + InfoZeile(87)))
  1425.                   else WriteRam(1,Y+Yofs,Attrib[4],1,EFillStr(80,B1,ConstStr(B1,20) + InfoZeile(88)));
  1426.                   Verzoegern(700);
  1427.                   DoPage(Y,Y);
  1428.                 end;
  1429.  
  1430.         _Del,
  1431.         _Esc  : Ende := true;
  1432.  
  1433.         _Tab  : begin
  1434.                   HoleLines(Kanal,Fpos);
  1435.                   DoPage(1,Zmax);
  1436.                 end;
  1437.  
  1438.         _Ret  : begin
  1439.                   if not RetFlag then
  1440.                   begin
  1441.                     if NoHeader(Lines^[Lpos]) then
  1442.                     begin
  1443.                       MakeRead(Kanal,0,Fail);
  1444.                       if Fail then Alarm;
  1445.                     end else Alarm;
  1446.                   end;
  1447.                   if RetFlag then
  1448.                   begin
  1449.                     Chr_Vor_Show(Kanal,_Ret,#13);
  1450.                     RetFlag := false;
  1451.                   end;
  1452.                 end;
  1453.  
  1454.         _F11,
  1455.         _Alt1..
  1456.         _Alt5 : begin
  1457.                   if KC = _F11 then
  1458.                   begin
  1459.                     KC := _Alt4;
  1460.                     VC := #123;
  1461.                   end;
  1462.                   if update then Updaten(Kanal);
  1463.                   Hstr := MakeStr(Lines^[Lpos],2,Attr);
  1464.                   Hch := Hstr[1];
  1465.                   if Hch in ['L','C'] then
  1466.                   begin
  1467.                     WriteRam(1,Y+Yofs,Attrib[4],1,EFillStr(80,B1,ConstStr(B1,20) + InfoZeile(39)));
  1468.                     Hstr := MakeStr(Lines^[Lpos],0,Attr);
  1469.  
  1470.                     A := ord(VC) - 119;
  1471.  
  1472.                     Bstr := ParmStr(A,B1,Hstr);
  1473.                     if A = 1 then Spalte := 1
  1474.                              else Spalte := ParmPos;
  1475.                     Bstr := ParmStr(A+1,B1,Hstr);
  1476.                     AnzSp := Byte(ParmPos - Spalte);
  1477.  
  1478.                     FreeMem(Lines,SizeOf(Lines^));
  1479.                     CheckSort(Kanal,Spalte,AnzSp,Fpos + Lpos - 1,Hch);
  1480.                     GetMem(Lines,SizeOf(Lines^));
  1481.                     HoleLines(Kanal,Fpos);
  1482.                     DoPage(1,Zmax);
  1483.                   end else Alarm;
  1484.                 end;
  1485.  
  1486.          _Ins : begin
  1487.                   VorEdit := true;
  1488.                   WriteRam(1,Y+Yofs,Attrib[4],1,ConstStr(#24,80));
  1489.                   Chr_Vor_Show(Kanal,_Nix,#255);
  1490.                 end;
  1491.  
  1492.         _AltC : begin
  1493.                   Hstr := MakeStr(Lines^[Lpos],0,Attr);
  1494.                   KillEndBlanks(Hstr);
  1495.                   VorWrite[Kanal]^[stV] := Hstr;
  1496.                   Chr_Vor_Show(Kanal,_End,#255);
  1497.                   Chr_Vor_Show(Kanal,_Alt7,#255);
  1498.                   if UpScroll then CursorUp(Kanal)
  1499.                               else CursorDown(Kanal);
  1500.                 end;
  1501.  
  1502.         _AltE : if NoHeader(Lines^[Lpos]) then
  1503.                 begin
  1504.                   MakeRead(Kanal,1,Fail);
  1505.                   if not Fail then
  1506.                   begin
  1507.                     if UpScroll then CursorUp(Kanal)
  1508.                                 else CursorDown(Kanal);
  1509.                   end else Alarm;
  1510.                 end else Alarm;
  1511.  
  1512.         _AltH : TOP_Help(G^.OHelp[29]);
  1513.  
  1514.         _AltF,
  1515.         _AltN : begin
  1516.                   if (KC = _AltF) or ((KC = _AltN) and (SuchStr = '')) then
  1517.                   begin
  1518.                     WriteRam(1,Y+Yofs,Attrib[4],1,EFillStr(80,B1,InfoZeile(7)));
  1519.                     GetString(Suchstr,Attrib[4],30,45,Y+Yofs,KC,0,Ins);
  1520.                   end;
  1521.                   if (KC <> _Esc) and (SuchStr > '') then
  1522.                   begin
  1523.                     Found := false;
  1524.                     Seek(DBox,Fpos + Lpos);
  1525.                     While not Found and not Eof(DBox) do
  1526.                     begin
  1527.                       BlockRead(DBox,HLstr,1,Result);
  1528.                       Hstr := UpCaseStr(MakeStr(HLstr,0,Attr));
  1529.                       Found := pos(SuchStr,Hstr) > 0;
  1530.                     end;
  1531.                     if Found then
  1532.                     begin
  1533.                       Fpos := FilePos(DBox) - Lpos;
  1534.                       if Fpos + maxL > FSize then
  1535.                       begin
  1536.                         Lpos := FilePos(DBox) + maxL - FSize;
  1537.                         Fpos := FSize - maxL;
  1538.                       end;
  1539.                       HoleLines(Kanal,Fpos);
  1540.                       if Lpos + Zmax - Y > maxL then Y := Lpos + Zmax - maxL;
  1541.                       DoPage(1,Zmax);
  1542.                     end else
  1543.                     begin
  1544.                       Seek(DBox,Fpos);
  1545.                       Alarm;
  1546.                     end;
  1547.                   end;
  1548.                   DoPage(Y,Y);
  1549.                 end;
  1550.  
  1551.         _AltP : begin
  1552.                   if LPT_vorhanden and Lpt_All_Ok(PrtPort) then
  1553.                   begin
  1554.                     Seek(DBox,Fpos + Lpos - 1);
  1555.                     While not Eof(DBox) and not PrtFailure do
  1556.                     begin
  1557.                       BlockRead(DBox,HLstr,1,Result);
  1558.                       Hstr := MakeStr(HLstr,0,Attr);
  1559.                       KillEndBlanks(Hstr);
  1560.                       YScrolPos := Y + Yofs;
  1561.                       Write_Drucker(Kanal,Hstr + M1);
  1562.                     end;
  1563.                     Seek(DBox,Fpos);
  1564.                   end else
  1565.                   begin
  1566.                     WriteRam(1,Y+Yofs,Attrib[4],1,EFillStr(80,B1,InfoZeile(290)));
  1567.                     Alarm;
  1568.                     Verzoegern(ZWEI);
  1569.                   end;
  1570.                   DoPage(Y,Y);
  1571.                 end;
  1572.  
  1573.         _AltS : begin
  1574.                   WriteRam(1,Y+Yofs,Attrib[4],1,EFillStr(80,B1,B1+InfoZeile(142)+B1));
  1575.                   Save_Name := G^.SavePfad + 'BOX'+ int_str(Kanal) + '.TXT';
  1576.                   GetString(Save_Name,Attrib[4],60,9,Y+Yofs,KC,1,Ins);
  1577.                   if KC <> _Esc then
  1578.                   begin
  1579.                     Assign(BoxSave,Save_Name);
  1580.                     Result := AppendTxt(BoxSave);
  1581.                     if Result <> 0 then Result := RewriteTxt(BoxSave);
  1582.                     if Result = 0 then
  1583.                     begin
  1584.                       Seek(DBox,Fpos + Lpos - 1);
  1585.                       While not Eof(DBox) do
  1586.                       begin
  1587.                         BlockRead(DBox,HLstr,1,Result);
  1588.                         Hstr := MakeStr(HLstr,0,Attr);
  1589.                         KillEndBlanks(Hstr);
  1590.                         Writeln(BoxSave,Hstr);
  1591.                       end;
  1592.                       FiResult := CloseTxt(BoxSave);
  1593.                       Seek(DBox,Fpos);
  1594.                     end else
  1595.                     begin
  1596.                       WriteRam(1,Y+Yofs,Attrib[4],1,EFillStr(80,B1,B1 +
  1597.                                         InfoZeile(75) + DP + B2 + Save_Name));
  1598.                       Alarm;
  1599.                       Verzoegern(ZWEI);
  1600.                     end;
  1601.                   end;
  1602.                   DoPage(Y,Y);
  1603.                 end;
  1604.  
  1605.        _AltF1.._AltF10
  1606.               : SETNr := Ord(VC) - 103;
  1607.  
  1608.       _CtrlF1 : if G^.SETL[SETNr] > 0 then dec(G^.SETL[SETNr])
  1609.                                       else Alarm;
  1610.  
  1611.       _CtrlF2 : if G^.SETL[SETNr] < 365 then inc(G^.SETL[SETNr])
  1612.                                         else Alarm;
  1613.  
  1614.        _Right : if X < 80 then inc(X) else Alarm;
  1615.  
  1616.         _Left : if X > 1 then dec(X) else Alarm;
  1617.  
  1618.           _Up : CursorUp(Kanal);
  1619.  
  1620.           _Dn : CursorDown(Kanal);
  1621.  
  1622.         _PgUp : if (Y > 1) or (Fpos + Lpos > 1) then
  1623.                 begin
  1624.                   Lpos := Lpos - Zmax + 1;
  1625.  
  1626.                   if Lpos - Y + 1 < 1 then
  1627.                   begin
  1628.                     Fpos := Fpos - maxL + Lpos + Zmax - Y;
  1629.                     Lpos := maxL - Zmax + Y;
  1630.                     if Fpos < 0 then
  1631.                     begin
  1632.                       Lpos := Lpos + Fpos;
  1633.                       Fpos := 0;
  1634.                     end;
  1635.                     HoleLines(Kanal,Fpos);
  1636.                   end;
  1637.  
  1638.                   if Lpos - Y + 1 < 1 then
  1639.                   begin
  1640.                     Lpos := 1;
  1641.                     Y := 1;
  1642.                   end;
  1643.  
  1644.                   DoPage(1,Zmax);
  1645.                 end else Alarm;
  1646.  
  1647.         _PgDn : if (Y < Zmax) or (Fpos + Lpos < FSize) then
  1648.                 begin
  1649.                   Lpos := Lpos + Zmax - 1;
  1650.  
  1651.                   if Lpos + Zmax - Y > maxL then
  1652.                   begin
  1653.                     Fpos := Fpos + Lpos - Y;
  1654.                     Lpos := Y;
  1655.                     if Fpos + maxL > FSize then
  1656.                     begin
  1657.                       Lpos := Fpos + maxL - FSize + Y;
  1658.                       Fpos := FSize - maxL;
  1659.                     end;
  1660.                     HoleLines(Kanal,Fpos);
  1661.                   end;
  1662.  
  1663.                   if Lpos + Zmax - Y > maxL then
  1664.                   begin
  1665.                     Lpos := maxL;
  1666.                     Y := Zmax;
  1667.                   end;
  1668.                   DoPage(1,Zmax);
  1669.                 end else Alarm;
  1670.  
  1671.     _CtrlPgUp : if (Y > 1) or (Fpos + Lpos > 1) then
  1672.                 begin
  1673.                   Fpos := 0;
  1674.                   Lpos := 1;
  1675.                   Y := 1;
  1676.                   HoleLines(Kanal,Fpos);
  1677.                   DoPage(1,Zmax);
  1678.                 end else Alarm;
  1679.  
  1680.     _CtrlPgDn : if (Y < Zmax) or (Fpos + Lpos < FSize) or First then
  1681.                 begin
  1682.                   First := false;
  1683.                   Fpos := FSize - maxL;
  1684.                   Lpos := maxL;
  1685.                   Y := Zmax;
  1686.                   HoleLines(Kanal,Fpos);
  1687.                   DoPage(1,Zmax);
  1688.                 end else Alarm;
  1689.  
  1690.         _Home : begin
  1691.                   Fpos := BoxZlnMerk;
  1692.                   Lpos := 1;
  1693.                   Y := 1;
  1694.                   if Fpos + maxL > FSize then
  1695.                   begin
  1696.                     Lpos := Fpos + maxL - FSize + Y;
  1697.                     Fpos := FSize - maxL;
  1698.                   end;
  1699.                   if Lpos + Zmax - Y > maxL then Y := Lpos + Zmax - maxL;
  1700.                   HoleLines(Kanal,Fpos);
  1701.                   DoPage(1,Zmax);
  1702.                 end;
  1703.  
  1704.         _End  : BoxZlnMerk := Fpos + Lpos - 1;
  1705.  
  1706.     _CtrlHome : begin
  1707.                   DoPage(Y,Y);
  1708.                   Lpos := Lpos - Y + 1;
  1709.                   Y := 1;
  1710.                 end;
  1711.  
  1712.      _CtrlEnd : begin
  1713.                   DoPage(Y,Y);
  1714.                   Lpos := Lpos + Zmax - Y;
  1715.                   Y := Zmax;
  1716.                 end;
  1717.  
  1718.        _ShTab : begin
  1719.                   CurObStat := not CurObStat;
  1720.                   if CurObStat then
  1721.                   begin
  1722.                     Xmerk := X;
  1723.                     X := ((NrStat[2]-1)*20)+1
  1724.                   end else X := XMerk;
  1725.                 end;
  1726.  
  1727.        _ShDel : begin
  1728.                   Fpos := 0;
  1729.                   Lpos := 1;
  1730.                   Y := 1;
  1731.                   Seek(DBox,0);
  1732.                   Truncate(DBox);
  1733.                   FSize := 0;
  1734.                   BoxZlnMerk := 0;
  1735.                   FillChar(Lines^,SizeOf(Lines^),0);
  1736.                   Teil_Bild_Loesch(minY,maxY,Attrib[18]);
  1737.                 end;
  1738.  
  1739.          _Nix : ;
  1740.  
  1741.            else Alarm;
  1742.       end;
  1743.  
  1744.       WriteAttr(1,Y+Yofs,80,Attrib[4],1);
  1745.       if HardCur and not VorEdit then
  1746.       begin
  1747.         if CurObStat then SetzeCursor(X,ObStat)
  1748.                      else SetzeCursor(X,Y+Yofs);
  1749.       end;
  1750.       Hstr := MakeStr(Lines^[Lpos],1,Attr);
  1751.       KillEndBlanks(Hstr);
  1752.  
  1753.       WriteRam(Nx+1,ObStat,Attrib[9],1,
  1754.        EFillStr(19,B1,EFillStr(9,B1,Hstr) +
  1755.                        SFillStr(5,B1,int_str(Fpos+Lpos)) +
  1756.                        SFillStr(4,B1,int_str(G^.SETL[SETNr])) ));
  1757.     Until Ende;
  1758.  
  1759.     if update then Updaten(Kanal);
  1760.     if not (SysArt in SysMenge) then CloseDBox(Kanal);
  1761.     FreeMem(Lines,SizeOf(Lines^));
  1762.     BoxScroll := false;
  1763.     Neu_Bild;
  1764.   end;
  1765. End;
  1766.  
  1767. Procedure CheckSort (* Kanal,Spalte,AnzSp : Byte; Dpos : LongInt; SC : Char *);
  1768. Const  maxSLines = 3000;
  1769.  
  1770. Type   LinePtr  = Array [1..maxSLines] of ^MbxZeile;
  1771.  
  1772. var    SFeld  : ^LinePtr;
  1773.        Mpos,
  1774.        Bpos,
  1775.        Epos   : LongInt;
  1776.        Hstr   : String[BoxRec];
  1777.        Hs     : MbxZeile;
  1778.        RFlag,
  1779.        bigger : Boolean;
  1780.        SC_Pos : Byte;
  1781.        maxS,
  1782.        i,Zx,
  1783.        Result : Word;
  1784.        Temp1,
  1785.        Temp2  : File;
  1786.  
  1787.   Procedure DBox_in_Buffer(Kanal : Byte);
  1788.   begin
  1789.     with K[Kanal]^ do
  1790.     begin
  1791.       Zx := 0;
  1792.       While (Zx < maxS) and (FilePos(DBox) <= Epos) do
  1793.       begin
  1794.         inc(Zx);
  1795.         BlockRead(DBox,SFeld^[Zx]^,1,Result);
  1796.       end;
  1797.       bigger := FilePos(DBox) <= Epos;
  1798.     end;
  1799.   end;
  1800.  
  1801.   Procedure SortBuffer(N : Word);
  1802.   Var  x,i,j  : Integer;
  1803.        Change : Boolean;
  1804.        CPtr   : Pointer;
  1805.   Begin
  1806.     if N > 1 then
  1807.     begin
  1808.       x := 1;
  1809.       While x <= N do x := x * 3 + 1;
  1810.       x := x div 3;
  1811.       While x > 0 do
  1812.       begin
  1813.         i := x;
  1814.         While i <= N do
  1815.         begin
  1816.           j := i - x;
  1817.           Change := true;
  1818.           While (j > 0) and Change do
  1819.           begin
  1820.             if copy(SFeld^[j]^,Spalte,AnzSp) >
  1821.                copy(SFeld^[j+x]^,Spalte,AnzSp) then
  1822.             begin
  1823.               CPtr := SFeld^[j+x];
  1824.               SFeld^[j+x] := SFeld^[j];
  1825.               SFeld^[j] := CPtr;
  1826.               j := j - x;
  1827.             end else Change := false;
  1828.           end;
  1829.           i := i + 1;
  1830.         end;
  1831.         x := x div 3;
  1832.       end;
  1833.     end;
  1834.   End;
  1835.  
  1836. Begin
  1837.   with K[Kanal]^ do
  1838.   begin
  1839.     SC_Pos := 82;
  1840.     Mpos := Dpos;
  1841.     Seek(DBox,Mpos);
  1842.     Repeat
  1843.       BlockRead(DBox,Hstr[1],1,Result);
  1844.       if Hstr[SC_Pos] = SC then inc(Mpos);
  1845.     Until Eof(DBox) or (Hstr[SC_Pos] <> SC);
  1846.  
  1847.     if Mpos > Dpos then
  1848.     begin
  1849.       dec(Mpos);
  1850.       Epos := Mpos;
  1851.       Repeat
  1852.         Seek(DBox,Mpos);
  1853.         BlockRead(DBox,Hstr[1],1,Result);
  1854.         if Hstr[SC_Pos] = SC then dec(Mpos);
  1855.       Until (Mpos < 0) or (Hstr[SC_Pos] <> SC);
  1856.       Bpos := Mpos + 1;
  1857.  
  1858.       maxS := 0;
  1859.       GetMem(SFeld,SizeOf(SFeld^));
  1860.       While (MaxAvail > 1000) and (maxS < maxSLines) do
  1861.       begin
  1862.         inc(maxS);
  1863.         GetMem(SFeld^[maxS],SizeOf(MbxZeile));
  1864.         FillChar(SFeld^[maxS]^,SizeOf(MbxZeile),0);
  1865.       end;
  1866.  
  1867.       Seek(DBox,Bpos);
  1868.       DBox_in_Buffer(Kanal);
  1869.       SortBuffer(Zx);
  1870.  
  1871.       if bigger then
  1872.       begin
  1873.         Assign(Temp1,G^.TempPfad + Tmp1Datei);
  1874.         FiResult := RewriteBin(Temp1,BoxRec);
  1875.         Assign(Temp2,G^.TempPfad + Tmp2Datei);
  1876.         FiResult := RewriteBin(Temp2,BoxRec);
  1877.  
  1878.         for i := 1 to Zx do BlockWrite(Temp1,SFeld^[i]^,1,Result);
  1879.  
  1880.         Repeat
  1881.           DBox_in_Buffer(Kanal);
  1882.           SortBuffer(Zx);
  1883.           i := 1;
  1884.           Seek(Temp1,0);
  1885.           if not Eof(Temp1) then
  1886.           begin
  1887.             BlockRead(Temp1,Hs,1,Result);
  1888.             RFlag := true;
  1889.           end else RFlag := false;
  1890.  
  1891.           Repeat
  1892.             if (not Eof(Temp1) or RFlag) and (i <= Zx) then
  1893.             begin
  1894.               if copy(SFeld^[i]^,Spalte,AnzSp) < copy(Hs,Spalte,AnzSp) then
  1895.               begin
  1896.                 BlockWrite(Temp2,SFeld^[i]^,1,Result);
  1897.                 inc(i);
  1898.               end else
  1899.               begin
  1900.                 BlockWrite(Temp2,Hs,1,Result);
  1901.                 if not Eof(Temp1) then
  1902.                 begin
  1903.                   BlockRead(Temp1,Hs,1,Result);
  1904.                   RFlag := true;
  1905.                 end else RFlag := false;
  1906.               end;
  1907.             end;
  1908.  
  1909.             if not RFlag and Eof(Temp1) then
  1910.             begin
  1911.               While i <= Zx do
  1912.               begin
  1913.                 BlockWrite(Temp2,SFeld^[i]^,1,Result);
  1914.                 inc(i);
  1915.               end;
  1916.             end;
  1917.  
  1918.             if i > Zx then
  1919.             begin
  1920.               if RFlag then BlockWrite(Temp2,Hs,1,Result);
  1921.               While not Eof(Temp1) do
  1922.               begin
  1923.                 BlockRead(Temp1,Hs,1,Result);
  1924.                 BlockWrite(Temp2,Hs,1,Result);
  1925.               end;
  1926.             end else
  1927.           Until Eof(Temp1) and (i > Zx);
  1928.  
  1929.           if bigger then
  1930.           begin
  1931.             FiResult := CloseBin(Temp1);
  1932.             FiResult := EraseBin(Temp1);
  1933.  
  1934.             FiResult := CloseBin(Temp2);
  1935.             Rename(Temp2,G^.TempPfad + Tmp1Datei);
  1936.  
  1937.             Assign(Temp1,G^.TempPfad + Tmp1Datei);
  1938.             FiResult := ResetBin(Temp1,BoxRec);
  1939.  
  1940.             Assign(Temp2,G^.TempPfad + Tmp2Datei);
  1941.             FiResult := RewriteBin(Temp2,BoxRec);
  1942.           end;
  1943.         Until not bigger;
  1944.  
  1945.         Seek(DBox,Bpos);
  1946.         Seek(Temp2,0);
  1947.         While not Eof(Temp2) do
  1948.         begin
  1949.           BlockRead(Temp2,Hs,1,Result);
  1950.           BlockWrite(DBox,Hs,1,Result);
  1951.         end;
  1952.  
  1953.         FiResult := CloseBin(Temp1);
  1954.         FiResult := CloseBin(Temp2);
  1955.         FiResult := EraseBin(Temp1);
  1956.         FiResult := EraseBin(Temp2);
  1957.       end else
  1958.       begin
  1959.         Seek(DBox,Bpos);
  1960.         for i := 1 to Zx do BlockWrite(DBox,SFeld^[i]^,1,Result);
  1961.       end;
  1962.       for i := 1 to maxS do FreeMem(SFeld^[i],SizeOf(MbxZeile));
  1963.       FreeMem(SFeld,SizeOf(SFeld^));
  1964.     end;
  1965.   end;
  1966. End;
  1967.  
  1968.  
  1969. Procedure OpenDBox (* Kanal : Byte *);
  1970. Begin
  1971.   with K[Kanal]^ do
  1972.   begin
  1973.     if not ChkLstOpen then
  1974.     begin
  1975.       if ResetBin(DBox,BoxRec) > 0 then FiResult := RewriteBin(DBox,BoxRec);
  1976.       FSize := FileSize(DBox);
  1977.       ChkLstOpen := true;
  1978.     end;
  1979.   end;
  1980. End;
  1981.  
  1982. Procedure CloseDBox(Kanal : Byte);
  1983. Var  Result : Word;
  1984. Begin
  1985.   with K[Kanal]^ do
  1986.   begin
  1987.     if ChkLstOpen then
  1988.     begin
  1989.       FiResult := CloseBin(DBox);
  1990.       ChkLstOpen := false;
  1991.     end;
  1992.   end;
  1993. End;
  1994.